<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class Console extends Window implements IRenderable {
	
	private $html;

	
	/**
	 * Constructeur
	 * @param unknown_type $id
	 * @param unknown_type $title
	 * @param unknown_type $width
	 * @param unknown_type $height
	 * @param unknown_type $htmlContent
	 */
	public function Console($id, $title) {
		parent::Window($title);
		
		$this->ID = $id;
		$this->canDragResize = true;
		$this->html = array();

		$this->html['mess'] = MessageCollectionLog::getInstance()->getMessage();
		$this->html['sco'] = ScCollectionLog::getInstance()->getMessage();
		$this->html['conf'] = $this->configRender(Config::getParams());
	}
	
	/**
	 * Renvoie le contenu de la fenetre configs
	 * @param unknown_type $objConfig
	 * @return string
	 */
	private function configRender($objConfig) {
		$l = get_object_vars($objConfig);
		$str = "<table style=\\\"width:100%;\\\">";
		foreach ($l as $prop => $value) {
			$str.= '<tr style=background:#eee;><td style=font-size:10px;>'.$prop.'</td><td style=font-size:10px;>'.$value.'</td></tr>';
		}
		$str.= "</table>";
		return $str;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return "Window";
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		//
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		return "isc.".$this->object().".create(
		{ID:\"".$this->ID."\",
		left:(isc.Canvas.getById(\"".Config::getParams()->ID_SCREEN."\").getInnerWidth() - 502),
		top:2,
		width:500,
		height:(isc.Canvas.getById(\"".Config::getParams()->ID_SCREEN."\").getInnerHeight()-4),
		title:\"".$this->title."\",
		showHeaderIcon:false,
		canDragResize:true,
		items:[
			isc.TabSet.create({
				paneMargin:0,
				tabs:[
					{ID:\"#mess_tab#\",title:\"Messages\",pane:isc.HTMLFlow.create({contents:\"".$this->html['mess']."\"})},
					{ID:\"#sco_tab#\",title:\"SmartClient Objects\",pane:isc.HTMLFlow.create({contents:\"".$this->html['sco']."\"})},
					{ID:\"#config_tab#\",title:\"Configuration\",pane:isc.HTMLFlow.create({contents:\"".$this->html['conf']."\"})}
					],
				ID:\"console_tab\"})
			  ]
			});";
	}
}
?>